import {Config} from '../../utils/conf.js';
import {httpReq} from '../../utils/http.js';

class answer
{
  //获取所有分类
  getcate(that){
    let obj = {};
    obj.url = Config.getcate;
    httpReq(obj).then(res=>{
      let arrs = [{id:0,cate:'请选择问题分类'}];
      res.data.data.forEach(element => {
        arrs.push({id:element.id,cate:element.cate});
      });
      that.setData({
        arr: arrs,
      })
    })
  }

  //获取分类下的素有问题
  getList(that,offset,cid){
    let obj = {};
    let hasq = true;
    obj.url = Config.getcateque + cid;
    obj.data = {offset,limit:10}
    httpReq(obj).then(res=>{
      if( offset == 0){
        that.data.rows = [];
      }
      if(res.data.data.length != 0){
        hasq = false;
      }
      that.setData({
        rows:that.data.rows.concat(res.data.data),
        limit: res.data.data.length + that.data.limit,
        hasq,
      })
    })
  }
  
}

export default answer;